home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / replace.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.2 KB  |  50 lines

  1. <!--- This example shows the use of Replace --->
  2. <HTML>
  3.  
  4. <HEAD>
  5. <TITLE>
  6. Replace Example
  7. </TITLE>
  8. </HEAD>
  9.  
  10. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  11. <BODY  bgcolor="#FFFFD5">
  12.  
  13. <H3>Replace Example</H3>
  14.  
  15. <P>The Replace function returns <I>string</I> with 
  16. <I>substring1</I> being replaced by <I>substring2</I> in
  17. the specified scope.  This is a case-sensitive search.
  18.  
  19. <CFIF IsDefined("form.MyString")>
  20.  
  21. <P>Your original string, <CFOUTPUT>#form.MyString#</CFOUTPUT>
  22. <P>You wanted to replace the substring <CFOUTPUT>#form.MySubstring1#</CFOUTPUT>
  23. with the substring <CFOUTPUT>#form.MySubstring2#</CFOUTPUT>.
  24. <P>The result: <CFOUTPUT>#Replace(form.myString, form.MySubstring1, form.mySubString2)#</CFOUTPUT>
  25.  
  26.  
  27.  
  28. </CFIF>
  29.  
  30. <FORM ACTION="replace.cfm" METHOD="POST">
  31. <P>String 1
  32. <BR><INPUT TYPE="Text" VALUE="My Test String" NAME="MyString">
  33.  
  34. <P>Substring 1 (find this substring)
  35. <BR><INPUT TYPE="Text" VALUE="Test" NAME="MySubstring1">
  36.  
  37. <P>Substring 2 (replace with this substring)
  38. <BR><INPUT TYPE="Text" VALUE="Replaced" NAME="MySubstring2">
  39.  
  40.  
  41. <P><INPUT TYPE="Submit" VALUE="Replace and display" NAME=""> 
  42.  
  43. </FORM>
  44.  
  45.  
  46. </BODY>
  47.  
  48. </HTML>       
  49.  
  50.